package com.lh.config;

import com.lh.bean.RespBean;
import com.lh.exception.MyException;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Configuration
@RestControllerAdvice
public class ExceptionHandler {
    @org.springframework.web.bind.annotation.ExceptionHandler(MyException.class)
    public RespBean myException(MyException e) {
        e.printStackTrace();
        return RespBean.error(e.getMessage());
    }

    @org.springframework.web.bind.annotation.ExceptionHandler(Exception.class)
    public RespBean exception(Exception e) {
        e.printStackTrace();
        return RespBean.error("未知错误，请联系管理员");
    }
}